<!DOCTYPE HTML>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-upkeepPlan-edit" th:object="${upkeepPlan}">
            <input id="planId" name="planId" th:field="*{planId}"  type="hidden">
			<div class="form-group">
				<label class="col-sm-3 control-label">电梯名称：</label>
				<div class="col-sm-8">
					<input th:field="*{elevatorInfo.elevatorName}" class="form-control" type="text" disabled>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">保养类型：</label>
				<div class="col-sm-8">
					<select id="upkeepType" name="upkeepType" th:field="*{upkeepType}" class="form-control m-b" th:with="type=${@dict.getType('business_upkeep_type')}">
						<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
					</select>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">保养模板：</label>
				<div class="col-sm-8">
					<select id="templateId" name="templateId" th:field="*{templateId}" class="form-control m-b">
						<option th:each="template : ${templateList}" th:text="${template.templateName}" th:value="${template.templateId}"></option>
					</select>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">保养间隔：</label>
				<div class="col-sm-8">
					<input id="upkeepInterval" name="upkeepInterval" th:field="*{upkeepInterval}" required class="form-control" type="number" readonly>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">首次保养时间：</label>
				<div class="col-sm-8">
					<input id="firstUpkeepTime" name="firstUpkeepTime" th:field="*{firstUpkeepTime}" class="form-control" type="text" disabled>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">最近保养时间：</label>
				<div class="col-sm-8">
					<input id="recentlyTime" name="recentlyTime" th:field="*{recentlyTime}" class="form-control" type="text" disabled>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">保养提醒天数：</label>
				<div class="col-sm-8">
					<input id="remindDay" name="remindDay" th:field="*{remindDay}" required class="form-control" type="number">
				</div>
			</div>
		</form>
    </div>
    <div th:include="include::footer"></div>
    <script type="text/javascript">
		var prefix = ctx + "business/upkeepPlan";
		$("#form-upkeepPlan-edit").validate({
			rules:{
				xxxx:{
					required:true,
				},
			}
		});
		
		function submitHandler() {
	        if ($.validate.form()) {
	            $.operate.save(prefix + "/edit", $('#form-upkeepPlan-edit').serialize());
	        }
	    }
        $("#upkeepInterval").val("15");
        $("#upkeepType").bind("change", function() {
			if($("#upkeepType").val() == 1){
				$("#upkeepInterval").val("15");
			}else if($("#upkeepType").val() == 2){
                $("#upkeepInterval").val("90");
			}else if($("#upkeepType").val() == 3){
                $("#upkeepInterval").val("180");
            }else if($("#upkeepType").val() == 4){
                $("#upkeepInterval").val("360");
            }
        });
	</script>
</body>
</html>
